<template>
  <div>
    <div v-if="saveLoading" class="flex-center" style="height: 400px">
      <div></div>
      <div><i class="el-icon-loading"></i>加载中...</div>
      <div></div>
    </div>
    <el-form
      v-else
      ref="addForm"
      :model="promotersForm"
      label-width="90px"
      class="m-l-40"
      label-position="left"
    >
      <el-form-item label="加注机厂家">
        <el-input
          type="input"
          v-model="promotersForm.supplierName"
          size="small"
          placeholder="请输入加注机厂家"
        ></el-input>
      </el-form-item>
      <el-form-item label="接口类名">
        <el-input
          type="input"
          v-model="promotersForm.interfaceClassName"
          size="small"
          placeholder="请输入接口类名"
        ></el-input>
      </el-form-item>
      <el-form-item label="接口URL">
        <el-input
          type="input"
          v-model="promotersForm.webServerUri"
          size="small"
          placeholder="请输入接口URL"
        ></el-input>
      </el-form-item>
      <el-form-item label="APPID">
        <el-input
          type="input"
          v-model="promotersForm.appid"
          size="small"
          placeholder="请输入APPID"
        ></el-input>
      </el-form-item>
      <el-form-item label="SECRET">
        <el-input
          type="input"
          v-model="promotersForm.secret"
          size="small"
          placeholder="请输入SECRET"
        ></el-input>
      </el-form-item>
      <div class="m-t-20 m-b-20"></div>
      <div class="flex-start">
        <el-button type="primary" size="small" plain @click="back"
          >取消</el-button
        >
        <el-button type="primary" size="small" @click="save">确定</el-button>
      </div>
    </el-form>
  </div>
</template>
<script>
import SelectFillingMachineButton from "@/components/business/select-filling-machine-button.vue";
import { fillmachineInterfaceadd as submit } from "@/api/system/user";
import { msgSuccess } from "@/util/common-util";

export default {
  components: { SelectFillingMachineButton },
  data() {
    return {
      saveLoading: false,
    };
  },
  props: {
    promotersType: {
      type: String,
      default: "",
    },
    promotersForm: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  methods: {
    back() {
      this.$emit("back");
    },
    save() {
      this.saveLoading = true;
      submit(this.promotersForm)
        .then((res) => {
          msgSuccess();
          this.back(true);
          this.saveLoading = false;
        })
        .catch(() => {
          this.saveLoading = false;
        });
    },
  },
};
</script>
